package com.sanctity.controller;

import com.sanctity.config.PatternProProperties;
import com.sanctity.domain.User;
import com.sanctity.service.UserService;
import com.sanctity.vo.UserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;

/***
 * @belongsProject spring-cloud
 * @description <用户服务后端控制器>
 * @author Sanct
 * @version 1.0.0
 * @create 2024/1/16 20:28
 **/

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

//    @Value("${pattern.dateformat}")
//    private String dateFormatPattern;

    @Autowired
    private PatternProProperties patternProProperties;

    @GetMapping("now")
    public String getNowDateTime(){
        return LocalDateTime.now().format(DateTimeFormatter.ofPattern(patternProProperties.getDateFormat()));
//        return LocalDateTime.now().format(DateTimeFormatter.ofPattern(dateFormatPattern));
    }

    @GetMapping("{id}")
    public UserVo getUserInfoById(@PathVariable Integer id){
        return userService.findById(id);
    }
}
